/*************************************************************************
	> File Name: word_convert.cc
	> Author: likang
	> Mail:  
	> Created Time: 2014年12月21日 星期日 23时41分08秒
 ************************************************************************/

#include<iostream>
#include<fstream>
#include<map>
#include<sstream>

using namespace std;

void word_convert(string file, string word) {
	map<string, string> trans_map;
	string key, value;
	ifstream map_file;
	map_file.open(file.c_str());

	while (map_file >> key >> value) {
		trans_map.insert(make_pair(key, value));
	}

	/**print map element
	map<string ,string>::iterator it = trans_map.begin();
	while (it != trans_map.end()) {
		cout << it->first << " " << it->second << endl;
		++it;
	}
	**/

	istringstream istream(word);
	string w;
	bool flag = true;
	while (istream >> w) {
		map<string, string>::const_iterator map_it = trans_map.find(w);
		if (map_it != trans_map.end()) {
			w = map_it->second;
		}
		if (flag) {
			flag = false;
		}
		else {
			cout << " ";
		}
		cout << w;
	}
}

int main(int argc, char **argv) {
	string word;
	while (getline(cin, word)) {
		cout << word << endl;
		word_convert(argv[1],word);
	}
	return 0;
}

